package com.base.controller;

import com.base.service.BaseService;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping(value = "/base")
public class BaseController {

    @Autowired
    BaseService baseService;

    @RequestMapping(value = "/show")
    public String show(){
        String show = baseService.show();
        return "success:" + show;
    }

    @RequestMapping(value = "/session")
    public String getSessionId(HttpServletRequest request, HttpSession httpSession) {
        HttpSession session = request.getSession();

        log.info("-----------------> {}", session);

        return session.getId() + " ===== " + httpSession.getId();
    }

}
